package cn.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolExecutorTest {
	public static void main(String[] args) {
		ExecutorService cachePool  = Executors.newCachedThreadPool();
		
		cachePool.execute(new Runnable(){
			public void run() {
				System.out.println("hello world!");
			}
		});
		
		
		
		
		
		
		for (int i = 0; i < 20; i++) {
			int index = 1;
			cachePool.execute(new Runnable(){
				public void run() {
					try {
						System.out.println(index + "---" + Thread.currentThread().getName());
						Thread.sleep(200);
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			});
		}
	}
}
